package com.Jancode.leetcode;

import java.util.ArrayList;
import java.util.List;

public class AllReachableNodes {
    class Solution {
        public List<Integer> findSmallestSetOfVertices(int n, List<List<Integer>> edges) {
            boolean[] isIndegreeExists = new boolean[n];

            for(List<Integer> edge : edges) {
                isIndegreeExists[edge.get(1)] = true;
            }

            List<Integer> requiredNodes = new ArrayList<>();

            for(int i = 0; i < n; i++) {
                if(!isIndegreeExists[i])
                    requiredNodes.add(i);
            }

            return requiredNodes;
        }
    }
}
